package com.gome.ss.core.download;


import com.gome.spiderkit.client.WebPage;
import com.gome.ss.core.queue.QueueCache;

public class SpiderResponse implements SpiderResponseInterface {

	private String pluginName = "";
	private String pluginQualified = "";
	private WebPage webPage = null;
	private int priority = QueueCache.defaultPriority;
	private int triedCount = 0;
	private int retryCount = 0;
	private RequestDataMap dataMap = new RequestDataMap();
	private Object cdata = null;
	private boolean needRetry = false;
	public String identity = "";
	private String currentPage = "0";
	
	public SpiderResponse(WebPage page, String pluginName, String pluginQualified, int priority, int triedCount, int retryCount) {
		this.webPage = page;
		this.pluginName = pluginName;
		this.pluginQualified = pluginQualified;
		this.priority = priority;
		this.triedCount = triedCount;
		this.retryCount = retryCount;
	}
	
	@Override
	public WebPage loadedPage() {
		// TODO Auto-generated method stub
		return this.webPage;
	}

	@Override
	public String getPluginName() {
		// TODO Auto-generated method stub
		return pluginName;
	}

	@Override
	public String getPluginQualified() {
		// TODO Auto-generated method stub
		return pluginQualified;
	}

	@Override
	public int getPriority() {
		// TODO Auto-generated method stub
		return priority;
	}
	
	@Override
	public int triedCount() {
		// TODO Auto-generated method stub
		return triedCount;
	}

	@Override
	public int retryCount() {
		// TODO Auto-generated method stub
		return retryCount;
	}

	@Override
	public RequestDataMap getDataMap() {
		// TODO Auto-generated method stub
		return dataMap;
	}

	@Override
	public Object getData() {
		// TODO Auto-generated method stub
		return cdata;
	}
	
	public void setCData(Object data) {
		cdata = data;
	}

	@Override
	public boolean needRetry() {
		// TODO Auto-generated method stub
		return needRetry;
	}

	@Override
	public void setRetry() {
		// TODO Auto-generated method stub
		needRetry = true;
	}
	
	@Override
	public String getID() {
		return this.identity;
	}

	@Override
	public String currentPage() {
		// TODO Auto-generated method stub
		return this.currentPage;
	}

	@Override
	public void setCurrentPage(String currentPage) {
		// TODO Auto-generated method stub
		this.currentPage = currentPage;
	}

	@Override
	public boolean isRetry() {
		// TODO Auto-generated method stub
		return this.triedCount > 1 ? true : false;
	}
}
